import request from '@/utils/request';

/**
 * 分页查询海运
 */
export async function pageOcean(params) {
  const res = await request.get('/order/ocean/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询海运列表
 */
export async function listOcean(params) {
  const res = await request.get('/order/ocean', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询海运
 */
export async function getOcean(id) {
  const res = await request.get('/order/ocean/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加海运
 */
export async function addOcean(data) {
  const res = await request.post('/order/ocean', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改海运
 */
export async function updateOcean(data) {
  const res = await request.put('/order/ocean', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除海运
 */
export async function removeOcean(id) {
  const res = await request.delete('/order/ocean/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
